h = 1/32;
dx = [h h];
mks = 10;

% Diffusion type
% ==================================================
visEmbeddedGrid('Ellipse-32.dat', false);
colormap([0.5 0.5 0.5
    1 1 1
    1 1 1]);

plotShade([10 8], dx, 'y', 1.0);
plotShade([10 9], dx, 'y', 1.0);
plotShade([10 10], dx, 'y', 1.0);
plotShade([10 11], dx, 'y', 1.0);
plotShade([10 12], dx, 'y', 1.0);

plotShade([11 8], dx, 'y', 1.0);
plotShade([11 9], dx, 'y', 1.0);
plotShade([11 10], dx, 'y', 1.0);
plotShade([11 11], dx, 'y', 1.0);
plotShade([11 12], dx, 'y', 1.0);

plotShade([12 8], dx, 'y', 1.0);
plotShade([12 9], dx, 'y', 1.0);
plotShade([12 10], dx, 'y', 1.0);
plotShade([12 11], dx, 'y', 1.0);

plotShade([13 8], dx, 'y', 1.0);

plot(12.5*dx(2), 10.5*dx(1), 'ko', ...
    'MarkerSize', mks, ...
    'MarkerFaceColor', 'k');

lc = [8 10] .* dx;
hc = [13 15] .* dx;
plot([lc(2) lc(2) hc(2) hc(2) lc(2)], ...
    [lc(1) hc(1) hc(1) lc(1) lc(1)], ...
    'k-.', 'LineWidth', 2);

plotEllipse([0.5 0.5], [0.125 0.25]);
axis([0 1 0 1]);

% Convection type
% ==================================================

% visEmbeddedGrid('Ellipse-32.dat', false);
% colormap([0.5 0.5 0.5
%     1 1 1
%     1 1 1]);
% 
% plotShade([12 9], dx, 'y', 1.0);
% plotShade([11 9], dx, 'y', 1.0);
% plotShade([10 9], dx, 'y', 1.0);
% 
% idx = [10.5 12.5] .* dx;
% upwind = [-0.467 0.782];
% upwind = upwind ./ norm(upwind, 2);
% n = [-0.402 -0.915];
% n = n ./ norm(n, 2);
% 
% plot(idx(2), idx(1), 'ko', ...
%     'MarkerFaceColor', 'k', ...
%     'MarkerSize', 10);
% 
% upwindLoc = idx + 2*h*upwind;
% plot(upwindLoc(2), upwindLoc(1), ...
%     'ko', 'MarkerSize', 10);
% plotSegment(idx, upwindLoc, 'k-', 2);
% 
% inLoc = idx + 2 * h * n;
% plot(inLoc(2), inLoc(1), ...
%     'ko', 'MarkerSize', 10);
% plotSegment(idx, inLoc, 'k--', 2);
% 
% plotSegment(upwindLoc, inLoc, 'k:', 2);
% 
% plotEllipse([0.5 0.5], [0.125 0.25]);


% Convection type
% ==================================================

visEmbeddedGrid('Ellipse-32.dat', false);
colormap([0.5 0.5 0.5
    1 1 1
    1 1 1]);

plotShade([21 9], dx, 'y', 1.0);
plotShade([21 10], dx, 'y', 1.0);
plotShade([21 11], dx, 'y', 1.0);

idx = [10.5 19.5] .* dx;
upwind = [0.467 0.782];
upwind = upwind ./ norm(upwind, 2);
n = [-0.402 0.915];
n = n ./ norm(n, 2);

plot(idx(2), idx(1), 'ko', ...
    'MarkerFaceColor', 'k', ...
    'MarkerSize', mks);

upwindLoc = idx + 2*h*upwind;
plot(upwindLoc(2), upwindLoc(1), ...
    'ks', 'MarkerSize', mks);
plotSegment(idx, upwindLoc, 'k-', 2);

inLoc = idx + 2 * h * n;
plot(inLoc(2), inLoc(1), ...
    'ko', 'MarkerSize', mks);
plotSegment(idx, inLoc, 'k--', 2);

%plotSegment(upwindLoc, inLoc, 'k:', 2);
midLoc = upwindLoc * (1.0/3) + inLoc * (2.0/3);
arrow3(upwindLoc(end:-1:1), midLoc(end:-1:1), 'k:2', 0.2, 0.4);
plotSegment(midLoc, inLoc, 'k:', 2);

lc = [9 19] .* dx;
hc = [14 24] .* dx;
plot([lc(2) lc(2) hc(2) hc(2) lc(2)], ...
    [lc(1) hc(1) hc(1) lc(1) lc(1)], ...
    'k-.', 'LineWidth', 2);

plotEllipse([0.5 0.5], [0.125 0.25]);
axis([0 1 0 1]);
